 $LOAD_PATH.unshift File.join(File.dirname(__FILE__),'../..','ext_pr1/lib')
 require 'ext_pr1_v4'
 
 def sum_(accu,n)
   
   while (n >= 0)
    accu += n
    n -= 1
   end 
   accu
end

# sum ::= (var) :: Nat x Nat -> Nat
# 
 def sum(n) 
   check_pre((n.nat?))
   sum_(0,n)
 end
 
  def potenz(x, n)
   check_pre((n.nat?))
    potenz_(x, n, x)
 end
 
 def potenz_(x, n, accu)
   
   while(n > 1)
     accu *= x
     n-=1
   end
   accu
 end